import mainExport from './main-export';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import ComponentRenderer from './component-renderer';

function isComponent(Component) {
  return Boolean(typeof Component === 'function' && Component.prototype.isReactComponent);
}

function renderComponent(Component, props, htmlElement) {
  const cel = React.createElement(Component, props);
  const component = ReactDOM.render(cel, htmlElement);
  return component;
}

const componentRenderer = new ComponentRenderer(isComponent, renderComponent);
export function get(Component = mainExport) {
  return componentRenderer.get(Component);
}
export function render(Component, props, htmlElement) {
  return componentRenderer.render(Component, props, htmlElement);
}
export function renderDefault(props, htmlElement) {
  return componentRenderer.renderDefault(props, htmlElement);
}
export { get as getComponent, get as getReactComponent, render as renderComponent, render as renderReactComponent, renderDefault as renderDefaultComponent, renderDefault as renderDefaultReactComponent };
export default renderDefault;